package com.fast.ctrl;


import com.alibaba.fastjson.JSONObject;
import com.fast.model.ProjectModel;
import com.fast.model.UserModel;
import com.fast.model.AddMediaRequest;
import com.fast.service.DemoTraceService;
import lombok.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RequestMapping("/mediaInfo")
@RestController
public class DemoCtrl {
    @Autowired
    private DemoTraceService demoTraceService;




    @GetMapping("/refreshES/v1")
    public Object refreshEsByComposition(@RequestBody List<String> mediaIds) {
        for (String mediaId : mediaIds) {
            System.out.println(mediaId);
        }

        JSONObject resp = new JSONObject();
        resp.put("code", 200);
        resp.put("msg", "success");
        resp.put("data", null);
        return resp;
    }


    @PostMapping("/testAddDraft")
    public Object testAddDraft(@RequestBody JSONObject param) {
        Tmp tmpParam = JSONObject.parseObject(param.toJSONString(), Tmp.class);
        System.out.println(param);
        // log.info("param={}", tmpParam);
        JSONObject resp = new JSONObject();
        resp.put("code", 200);
        resp.put("msg", "success");
        resp.put("data", null);
        return resp;
    }

    @Setter
    @Getter
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Tmp {
        private AddMediaRequest request;
        private UserModel user;
        private ProjectModel project;
    }

    @PostMapping("/testAddDraft2")
    public String testAddDraft(@RequestBody String param) {
        Tmp tmpParam = JSONObject.parseObject(param, Tmp.class);
        // log.info("param={}", tmpParam);
        return ("ok");
    }
}
